﻿using springFramework = Spring.Aop.Framework;

namespace Itau.IM.Common.Aop.Factory
{
    public class ProxyFactory
    {
        /// <summary>
        /// Método responsável por criar o proxy para acesso à classe de implmentação
        /// </summary>
        /// <param name="implementation_">Classe de implementação</param>
        /// <param name="routineName_">Nome da rotina</param>
        /// <returns>Proxy</returns>
        public object Create(object implementation_, string routineName_)
        {
            springFramework.ProxyFactory factory = new springFramework.ProxyFactory(implementation_);
            AspectTraceBeforeMethod beforeAdvice = new AspectTraceBeforeMethod(routineName_);

            factory.AddAdvice(beforeAdvice);
            factory.AddAdvice(new AspectTraceAfterMethod(beforeAdvice));

            return factory.GetProxy();
        }
    }
}